---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-18-132a24e86cb2> in <module>
1 with pm.Model() as model:
----> 2 dens = pm.DensityDist('density', logp=dens_fn)
3 trace = pm.sample(5000)
4
~/miniconda3/envs/python3/lib/python3.7/site-packages/pymc3/distributions/distribution.py in __new__(cls, name, *args, **kwargs)
45 total_size = kwargs.pop('total_size', None)
46 dist = cls.dist(*args, **kwargs)
---> 47 return model.Var(name, dist, data, total_size)
48 else:
49 raise TypeError("Name needs to be a string but got: {}".format(name))
~/miniconda3/envs/python3/lib/python3.7/site-packages/pymc3/model.py in Var(self, name, dist, data, total_size)
920 with self:
921 var = FreeRV(name=name, distribution=dist,
--> 922 total_size=total_size, model=self)
923 self.free_RVs.append(var)
924 else:
~/miniconda3/envs/python3/lib/python3.7/site-packages/pymc3/model.py in __init__(self, type, owner, index, name, distribution, total_size, model)
1371 # The logp might need scaling in minibatches.
1372 # This is done in `Factor`.
-> 1373 self.logp_sum_unscaledt = distribution.logp_sum(self)
1374 self.logp_nojac_unscaledt = distribution.logp_nojac(self)
1375 self.total_size = total_size
~/miniconda3/envs/python3/lib/python3.7/site-packages/pymc3/distributions/distribution.py in logp_sum(self, *args, **kwargs)
122 if only the sum of the logp values is needed.
123 """
--> 124 return tt.sum(self.logp(*args, **kwargs))
125
126 __latex__ = _repr_latex_
~/miniconda3/envs/python3/lib/python3.7/site-packages/theano/tensor/basic.py in sum(input, axis, dtype, keepdims, acc_dtype)
3208 """
3209
-> 3210 out = elemwise.Sum(axis=axis, dtype=dtype, acc_dtype=acc_dtype)(input)
3211
3212 if keepdims:
~/miniconda3/envs/python3/lib/python3.7/site-packages/theano/gof/op.py in __call__(self, *inputs, **kwargs)
623 for i, ins in enumerate(node.inputs):
624 try:
--> 625 storage_map[ins] = [self._get_test_value(ins)]
626 compute_map[ins] = [True]
627 except AttributeError:
~/miniconda3/envs/python3/lib/python3.7/site-packages/theano/gof/op.py in _get_test_value(cls, v)
560 # ensure that the test value is correct
561 try:
--> 562 ret = v.type.filter(v.tag.test_value)
563 except Exception as e:
564 # Better error message.
~/miniconda3/envs/python3/lib/python3.7/site-packages/theano/tensor/type.py in filter(self, data, strict, allow_downcast)
85 if isinstance(data, Variable):
86 raise TypeError(
---> 87 'Expected an array-like object, but found a Variable: '
88 'maybe you are trying to call a function on a (possibly '
89 'shared) variable instead of a numeric array?')
TypeError: For compute_test_value, one input test value does not have the requested type.
Backtrace when that variable is created:
File "/Users/balarsen/miniconda3/envs/python3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3063, in run_cell_async
interactivity=interactivity, compiler=compiler, result=result)
File "/Users/balarsen/miniconda3/envs/python3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3254, in run_ast_nodes
if (await self.run_code(code, result, async_=asy)):
File "/Users/balarsen/miniconda3/envs/python3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3331, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-18-132a24e86cb2>", line 2, in <module>
dens = pm.DensityDist('density', logp=dens_fn)
File "/Users/balarsen/miniconda3/envs/python3/lib/python3.7/site-packages/pymc3/distributions/distribution.py", line 47, in __new__
return model.Var(name, dist, data, total_size)
File "/Users/balarsen/miniconda3/envs/python3/lib/python3.7/site-packages/pymc3/model.py", line 922, in Var
total_size=total_size, model=self)
File "/Users/balarsen/miniconda3/envs/python3/lib/python3.7/site-packages/pymc3/model.py", line 1373, in __init__
self.logp_sum_unscaledt = distribution.logp_sum(self)
File "/Users/balarsen/miniconda3/envs/python3/lib/python3.7/site-packages/pymc3/distributions/distribution.py", line 124, in logp_sum
return tt.sum(self.logp(*args, **kwargs))
The error when converting the test value to that variable type:
Expected an array-like object, but found a Variable: maybe you are trying to call a function on a (possibly shared) variable instead of a numeric array?